<?php
/**
 * Article(文章管理)
 */
namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class ArticleController extends AdminbaseController
{
    protected $article_model;

    public function _initialize()
    {
        parent::_initialize();
        $this->article_model = D("Common/Article");
    }

    // 提现规则
    public function money()
    {
        $type = I('request.type');
        $article = $this->article_model->where([
            'type'=>$type
        ])->select();
        $this->assign('article',$article[0]);
        $this->display('index');
    }
    // 接车点
    public function bus()
    {
        $type = I('request.type');
        $article = $this->article_model->where([
            'type'=>$type
        ])->select();
        $this->assign('article',$article[0]);
        $this->display('index');
    }

    public function content(){
        $type = I('type');
        $article = $this->article_model->where([
            'type'=>$type
        ])->select();
        if(empty($article)){
            $_POST['created_time'] = time();
            $article_obj = $_POST;
            if ($this->article_model->add($article_obj) !== false) {
                $this->success("修改成功");
            } else {
                $this->error("更新失败！");
            }
        }else{
            $article_obj = $_POST;
            $article_obj['updatad_time'] = time();
            $article_obj['id'] = $article[0]['id'];
            $result=$this->article_model->save($article_obj);
            if ($result !== false) {
                $this->success("修改成功");
            }else{
                $this->error("更新失败！");
            }
        }
    }
}
